﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace GSdk.Shared
{
    public static class LambdaExpressionExtensionMethods
    {
        public static string MemberToString(this LambdaExpression expression)
        {
            var memberexp = expression.Body as MemberExpression;
            if (memberexp == null)
                throw new ArgumentException("Failed to get name of expression member", "expression");
            return memberexp.Member.Name;
        }

        public static string MethodToString(this LambdaExpression expression)
        {
            var methodexp = expression.Body as MethodCallExpression;
            if (methodexp == null)
                throw new ArgumentException("Failed to get name of expression method", "expression");
            return methodexp.Method.Name;
        }
    }
}
